<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>财务管理-老人缴费结算</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/caiwu_assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/caiwu_assets/css/style.css" rel="stylesheet">
	<link href="/caiwu_assets/css/font-awesome.css" rel="stylesheet">
</head>

<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 财务管理</span><b class="fa fa-caret-right"></b><i>老人缴费结算</i></div>
			</div>
			<div class="seltemple">
				<div class="col-xs-12">
					<form class="form-inline form" method="get" action="/admin_elderlypayment">
					<div class="col-xs-3 mes-group"><label>老人姓名</label><input type="text" name="name"></div>
                    <div class="col-xs-3 mes-group"><label>所在部门</label><select name="department"><option value="0">不限</option><?foreach($tDIDatas as $tDIRow){?><option value="<?=$tDIRow['num']?>" <?if($tDIRow['num'] == $pDepartment)echo 'selected';?>><?=$tDIRow['introduce']?></option><?}?></select><button type="button" id="search">查询</button></div>
					
				</form>
				</div>
			</div>
			<div  class="mes-conttent col-xs-12" >
				<table class="table off-table"style="margin-top:.2rem">
	              <thead>
	             	<tr>
			        <th>编号</th>
			        <th>所在部门</th>
			        <th>老人姓名</th>
			        <th>基本费用</th>
			        <th>付费方式</th>
			        <th>付费折扣</th>
			        <th>老人入院时间</th>
			        <th>逾期付费时间</th>
			        <th>付费金额</th>
			        <th>付费次数</th>
			        <th>是否付费</th>
			        <th>查看缴费记录</th>
		            </tr>
	              </thead>
	             <tbody>
                    <?foreach($tDatas as $tRow){?>
                    <tr>
                        <td name="sid"><?=$tRow['id']?></td>
                        <td><?=$tRow['department']?></td>
                        <td><?=$tRow['name']?></td>
                        <td name="basic_fee"><?=$tRow['basic_fee']?></td>
                        <td name="payment" data="<?=$tRow['payment_num']?>"><?=$tRow['payment']?></td>
                        <td name="discount" data="<?=$tRow['discount_num']?>"><?=$tRow['discount']?></td>
                        <td name="created"><?=date('Y-m-d',$tRow['created'])?></td>
                        <td name="lasttime"><?=date('Y-m-d',$tRow['lasttime'])?></td>
                        <td><?if($tRow['is_pay'] == '2'){?><input type="text" name="fee" value="" placeholder="请输入金额数"/><?}else{?><?=$tRow['fee']?><?}?></td>
                        <td><? if(empty($tRow['paytimes'])){echo '0';}else{echo $tRow['paytimes'];}?></td>
                        <td><?if($tRow['is_pay'] == '1'){?><span>已付费</span><?}else{?><button type="button" class="issueBtn">确认付费</button><?}?></td>
                        <td>
                            <button type="button" onclick="location.href='/admin_elderlypayment/detail?id=<?=$tRow['id']?>';">查看</button>

                        </td>
                    </tr>
                    <?}?>
	            </tbody>
              </table>
            <?=$tShow?>
			</div>
		</div>
    </div>
        <script type="text/javascript" src="/caiwu_assets/js/jquery.min.js"></script>
<script>
$('#search').click(function(){
    $('form').submit();
});
/*获取地址栏参数*/
function GetQuery(key){
	var search = location.search.slice(1);//得到get方式提交的查询字符串
	var arr = search.split("&");
	for(var i = 0; i < arr.length; i++){
		var ar = arr[i].split("=");
		if(ar[0] == key){
			return ar[1];
		}
	}
}
    var color="#eeeeee";
    $("#table_list tr:odd td").css("background-color",color);  //改变偶数行背景色
    /* 把背景色保存到属性中 */
    $("#table_list tr:odd").attr("bg",color);

    $('.issueBtn').each(function(){
        $(this).on('click',function(){
            var sid = $(this).parent().parent().find('td[name="sid"]').text();
            var basic_fee = $(this).parent().parent().find('td[name="basic_fee"]').text();
            var payment = $(this).parent().parent().find('td[name="payment"]').attr('data');
            var discount = $(this).parent().parent().find('td[name="discount"]').attr('data');
            var lasttime = $(this).parent().parent().find('td[name="lasttime"]').text();
            var fee = $(this).parent().parent().find('input[name="fee"]').val();
            $.post('/admin_elderlypayment',{ sid:sid,basic_fee:basic_fee,payment:payment,discount:discount,lasttime:lasttime,fee:fee },function(obj){
                if(obj.status == 0){
                    alert(obj.msg);return;
                }else{
                    alert(obj.msg);location.href="/admin_elderlypayment";
                }
            });
        });    
    });
</script>
</body>
</html>
